package com.hongxun.design.ui.dragview;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.hongxun.design.R;
import com.hongxun.design.bean.PhotoPassagewayItemBean;
import com.hongxun.design.mytools.MyLog;
import com.hongxun.design.utils.imageutil.UriUtil;


public class TextImageItem extends RelativeLayout {
    private Context mContext = null;
    private SimpleDraweeView icon;
    private TextView name;
    private String touchUrl;


    private PhotoPassagewayItemBean itemBean=new PhotoPassagewayItemBean();



    public PhotoPassagewayItemBean getItemBean() {
        return itemBean;
    }



    public TextImageItem(Context context) {
        super(context);
        MyLog.L("进入ImageTextItem(Context context)");
        mContext = context;
        LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View parentView = inflater.inflate(R.layout.ui_textimageitem, this, true);
        icon = (SimpleDraweeView) parentView.findViewById(R.id.passageway_icon);
        name = (TextView) parentView.findViewById(R.id.passageway_name);

    }

    public TextImageItem(Context context, AttributeSet attrs) {
        super(context, attrs);
        MyLog.L("进入ImageTextItem(Context context, AttributeSet attrs)");
        mContext = context;

//        LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//        View parentView = inflater.inflate(R.layout.ui_imagetextitem, this, true);
//        icon = (SimpleDraweeView) parentView.findViewById(R.id.passageway_icon);
//        name = (TextView) parentView.findViewById(R.id.passageway_name);
//        value = (TextView) parentView.findViewById(R.id.passageway_value);

    }

    @Override
    protected void onFinishInflate() {
//        icon = (ImageView) findViewById(R.id.passageway_icon);
//        name = (TextView)  findViewById(R.id.passageway_name);
//        value = (TextView) findViewById(R.id.passageway_value);

        super.onFinishInflate();
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        return true;
    }
    public void setImage (String url) {
        if (icon != null) {
            icon.setImageURI(UriUtil.getUri(url));
        }
    }
    public void setName(String title) {
        if (name != null) {
            name.setText(title);
        }
    }

}
